package com.jk.controller;

import com.jk.pojo.BookEntity;
import com.jk.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("book")
public class BookController {

    @Autowired
    private BookService bookService;

    /**
    * @Author: wh
    * @Description: 分页+条查
    * @Date: 2021/5/18 23:18
    * @Param:[book]
    * @Return: java.util.HashMap<java.lang.String,java.lang.Object>
    **/
    @GetMapping
    public HashMap<String,Object> find(BookEntity book){
        return bookService.find(book);
    }

    /**
    * @Author: wh
    * @Description: 新增or修改
    * @Date: 2021/5/18 23:34
    * @Param:[book]
    * @Return: void
    **/
    @PostMapping
    public void addorup(BookEntity book){
        bookService.addorup(book);
    }

    /**
    * @Author: wh
    * @Description: 删除
    * @Date: 2021/5/18 23:34
    * @Param:[id]
    * @Return: void
    **/
    @DeleteMapping
    public void del(Integer id){
        bookService.del(id);
    }

    /**
    * @Author: wh
    * @Description: 修改回显
    * @Date: 2021/5/18 23:35
    * @Param:[id]
    * @Return: com.jk.pojo.BookEntity
    **/
    @RequestMapping("findById")
    public BookEntity findById(Integer id){
        return bookService.findById(id);
    }
}
